/**
 * @description: 检查项目id是否存在
 */
exports.idValidator = (ctx, next) => {
  const { id } = ctx.request.body;
  const { id: idParam } = ctx.params;
  if (!id && !idParam) return ctx.fail("id不能为空！");
  return next();
}

/**
 * @description: 排序移动表单校验
 */
exports.sortValidator = (ctx, next) => {
  const { fromId, toId } = ctx.request.body;
  if (!fromId || !toId) return ctx.fail("移动Id或目标Id不能为空！");
  ctx.state.sortForm = [+fromId, +toId];
  return next();
}
